package com.auto.autoapp

import android.os.Bundle
import android.view.View
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.navigation.findNavController
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.setupActionBarWithNavController
import androidx.navigation.ui.setupWithNavController
import com.auto.autoapp.adapter.TabAdapter
import com.auto.autoapp.base.BaseActivity
import com.auto.autoapp.databinding.ActivityMainBinding
import com.google.android.material.bottomnavigation.BottomNavigationView

class MainActivity : BaseActivity() {

    private lateinit var binding: ActivityMainBinding
    override fun provideView(): View {
        binding = ActivityMainBinding.inflate(layoutInflater)
        return binding.root
    }

    override fun showToolbar(): Boolean {
        return false
    }

    override fun onInit() {
        val navView: BottomNavigationView = binding.navView
        val pagerTab = binding.pagerTab
        val pageAdapter = TabAdapter(this)
        pagerTab.adapter = pageAdapter
        pagerTab.isUserInputEnabled = false
        pagerTab.offscreenPageLimit = 2
        navView.setOnItemSelectedListener { menuItem ->
            when (menuItem.itemId) {
                R.id.navigation_home -> {
                    pagerTab.currentItem = 0
                    true
                }

                R.id.navigation_dashboard -> {
                    pagerTab.currentItem = 1
                    true
                }

                R.id.navigation_notifications -> {
                    pagerTab.currentItem = 2
                    true
                }

                else -> false
            }
        }
    }
}